import 'package:flutter_deer/generated/json/base/json_convert_content.dart';
import 'package:flutter_deer/database/beans/pay/pay_result_entity.dart';

PayResultEntity $PayResultEntityFromJson(Map<String, dynamic> json) {
  final PayResultEntity payResultEntity = PayResultEntity();
  final bool? ablePay = jsonConvert.convert<bool>(json['ablePay']);
  if (ablePay != null) {
    payResultEntity.ablePay = ablePay;
  }
  final String? disablePayMsg = jsonConvert.convert<String>(json['disablePayMsg']);
  if (disablePayMsg != null) {
    payResultEntity.disablePayMsg = disablePayMsg;
  }
  final String? mchCode = jsonConvert.convert<String>(json['mchCode']);
  if (mchCode != null) {
    payResultEntity.mchCode = mchCode;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['orderAmount']);
  if (orderAmount != null) {
    payResultEntity.orderAmount = orderAmount;
  }
  final String? orderCode = jsonConvert.convert<String>(json['orderCode']);
  if (orderCode != null) {
    payResultEntity.orderCode = orderCode;
  }
  final int? orderConfigTime = jsonConvert.convert<int>(json['orderConfigTime']);
  if (orderConfigTime != null) {
    payResultEntity.orderConfigTime = orderConfigTime;
  }
  final int? orderId = jsonConvert.convert<int>(json['orderId']);
  if (orderId != null) {
    payResultEntity.orderId = orderId;
  }
  final int? orderStatus = jsonConvert.convert<int>(json['orderStatus']);
  if (orderStatus != null) {
    payResultEntity.orderStatus = orderStatus;
  }
  final String? orderTime = jsonConvert.convert<String>(json['orderTime']);
  if (orderTime != null) {
    payResultEntity.orderTime = orderTime;
  }
  final int? paidAmount = jsonConvert.convert<int>(json['paidAmount']);
  if (paidAmount != null) {
    payResultEntity.paidAmount = paidAmount;
  }
  final List<PayResultPayResponse>? payResponse = (json['payResponse'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PayResultPayResponse>(e) as PayResultPayResponse).toList();
  if (payResponse != null) {
    payResultEntity.payResponse = payResponse;
  }
  final PayResultPayResult? payResult = jsonConvert.convert<PayResultPayResult>(json['payResult']);
  if (payResult != null) {
    payResultEntity.payResult = payResult;
  }
  final String? tradeNo = jsonConvert.convert<String>(json['tradeNo']);
  if (tradeNo != null) {
    payResultEntity.tradeNo = tradeNo;
  }
  return payResultEntity;
}

Map<String, dynamic> $PayResultEntityToJson(PayResultEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['ablePay'] = entity.ablePay;
  data['disablePayMsg'] = entity.disablePayMsg;
  data['mchCode'] = entity.mchCode;
  data['orderAmount'] = entity.orderAmount;
  data['orderCode'] = entity.orderCode;
  data['orderConfigTime'] = entity.orderConfigTime;
  data['orderId'] = entity.orderId;
  data['orderStatus'] = entity.orderStatus;
  data['orderTime'] = entity.orderTime;
  data['paidAmount'] = entity.paidAmount;
  data['payResponse'] = entity.payResponse?.map((v) => v.toJson()).toList();
  data['payResult'] = entity.payResult?.toJson();
  data['tradeNo'] = entity.tradeNo;
  return data;
}

extension PayResultEntityExtension on PayResultEntity {
  PayResultEntity copyWith({
    bool? ablePay,
    String? disablePayMsg,
    String? mchCode,
    String? orderAmount,
    String? orderCode,
    int? orderConfigTime,
    int? orderId,
    int? orderStatus,
    String? orderTime,
    int? paidAmount,
    List<PayResultPayResponse>? payResponse,
    PayResultPayResult? payResult,
    String? tradeNo,
  }) {
    return PayResultEntity()
      ..ablePay = ablePay ?? this.ablePay
      ..disablePayMsg = disablePayMsg ?? this.disablePayMsg
      ..mchCode = mchCode ?? this.mchCode
      ..orderAmount = orderAmount ?? this.orderAmount
      ..orderCode = orderCode ?? this.orderCode
      ..orderConfigTime = orderConfigTime ?? this.orderConfigTime
      ..orderId = orderId ?? this.orderId
      ..orderStatus = orderStatus ?? this.orderStatus
      ..orderTime = orderTime ?? this.orderTime
      ..paidAmount = paidAmount ?? this.paidAmount
      ..payResponse = payResponse ?? this.payResponse
      ..payResult = payResult ?? this.payResult
      ..tradeNo = tradeNo ?? this.tradeNo;
  }
}

PayResultPayResponse $PayResultPayResponseFromJson(Map<String, dynamic> json) {
  final PayResultPayResponse payResultPayResponse = PayResultPayResponse();
  final String? failReason = jsonConvert.convert<String>(json['failReason']);
  if (failReason != null) {
    payResultPayResponse.failReason = failReason;
  }
  final String? finishTime = jsonConvert.convert<String>(json['finishTime']);
  if (finishTime != null) {
    payResultPayResponse.finishTime = finishTime;
  }
  final int? orderFinanceId = jsonConvert.convert<int>(json['orderFinanceId']);
  if (orderFinanceId != null) {
    payResultPayResponse.orderFinanceId = orderFinanceId;
  }
  final int? orderId = jsonConvert.convert<int>(json['orderId']);
  if (orderId != null) {
    payResultPayResponse.orderId = orderId;
  }
  final String? payCode = jsonConvert.convert<String>(json['payCode']);
  if (payCode != null) {
    payResultPayResponse.payCode = payCode;
  }
  final String? payMethod = jsonConvert.convert<String>(json['payMethod']);
  if (payMethod != null) {
    payResultPayResponse.payMethod = payMethod;
  }
  final String? payMsg = jsonConvert.convert<String>(json['payMsg']);
  if (payMsg != null) {
    payResultPayResponse.payMsg = payMsg;
  }
  final int? payStatus = jsonConvert.convert<int>(json['payStatus']);
  if (payStatus != null) {
    payResultPayResponse.payStatus = payStatus;
  }
  final String? payTime = jsonConvert.convert<String>(json['payTime']);
  if (payTime != null) {
    payResultPayResponse.payTime = payTime;
  }
  final String? payType = jsonConvert.convert<String>(json['payType']);
  if (payType != null) {
    payResultPayResponse.payType = payType;
  }
  final String? prePayTn = jsonConvert.convert<String>(json['prePayTn']);
  if (prePayTn != null) {
    payResultPayResponse.prePayTn = prePayTn;
  }
  final bool? success = jsonConvert.convert<bool>(json['success']);
  if (success != null) {
    payResultPayResponse.success = success;
  }
  return payResultPayResponse;
}

Map<String, dynamic> $PayResultPayResponseToJson(PayResultPayResponse entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['failReason'] = entity.failReason;
  data['finishTime'] = entity.finishTime;
  data['orderFinanceId'] = entity.orderFinanceId;
  data['orderId'] = entity.orderId;
  data['payCode'] = entity.payCode;
  data['payMethod'] = entity.payMethod;
  data['payMsg'] = entity.payMsg;
  data['payStatus'] = entity.payStatus;
  data['payTime'] = entity.payTime;
  data['payType'] = entity.payType;
  data['prePayTn'] = entity.prePayTn;
  data['success'] = entity.success;
  return data;
}

extension PayResultPayResponseExtension on PayResultPayResponse {
  PayResultPayResponse copyWith({
    String? failReason,
    String? finishTime,
    int? orderFinanceId,
    int? orderId,
    String? payCode,
    String? payMethod,
    String? payMsg,
    int? payStatus,
    String? payTime,
    String? payType,
    String? prePayTn,
    bool? success,
  }) {
    return PayResultPayResponse()
      ..failReason = failReason ?? this.failReason
      ..finishTime = finishTime ?? this.finishTime
      ..orderFinanceId = orderFinanceId ?? this.orderFinanceId
      ..orderId = orderId ?? this.orderId
      ..payCode = payCode ?? this.payCode
      ..payMethod = payMethod ?? this.payMethod
      ..payMsg = payMsg ?? this.payMsg
      ..payStatus = payStatus ?? this.payStatus
      ..payTime = payTime ?? this.payTime
      ..payType = payType ?? this.payType
      ..prePayTn = prePayTn ?? this.prePayTn
      ..success = success ?? this.success;
  }
}

PayResultPayResult $PayResultPayResultFromJson(Map<String, dynamic> json) {
  final PayResultPayResult payResultPayResult = PayResultPayResult();
  final String? failReason = jsonConvert.convert<String>(json['failReason']);
  if (failReason != null) {
    payResultPayResult.failReason = failReason;
  }
  final String? finishTime = jsonConvert.convert<String>(json['finishTime']);
  if (finishTime != null) {
    payResultPayResult.finishTime = finishTime;
  }
  final String? orderFinanceId = jsonConvert.convert<String>(json['orderFinanceId']);
  if (orderFinanceId != null) {
    payResultPayResult.orderFinanceId = orderFinanceId;
  }
  final String? orderId = jsonConvert.convert<String>(json['orderId']);
  if (orderId != null) {
    payResultPayResult.orderId = orderId;
  }
  final String? payCode = jsonConvert.convert<String>(json['payCode']);
  if (payCode != null) {
    payResultPayResult.payCode = payCode;
  }
  final String? payMethod = jsonConvert.convert<String>(json['payMethod']);
  if (payMethod != null) {
    payResultPayResult.payMethod = payMethod;
  }
  final String? payMsg = jsonConvert.convert<String>(json['payMsg']);
  if (payMsg != null) {
    payResultPayResult.payMsg = payMsg;
  }
  final int? payStatus = jsonConvert.convert<int>(json['payStatus']);
  if (payStatus != null) {
    payResultPayResult.payStatus = payStatus;
  }
  final String? payTime = jsonConvert.convert<String>(json['payTime']);
  if (payTime != null) {
    payResultPayResult.payTime = payTime;
  }
  final String? payType = jsonConvert.convert<String>(json['payType']);
  if (payType != null) {
    payResultPayResult.payType = payType;
  }
  final String? prePayTn = jsonConvert.convert<String>(json['prePayTn']);
  if (prePayTn != null) {
    payResultPayResult.prePayTn = prePayTn;
  }
  final bool? success = jsonConvert.convert<bool>(json['success']);
  if (success != null) {
    payResultPayResult.success = success;
  }
  return payResultPayResult;
}

Map<String, dynamic> $PayResultPayResultToJson(PayResultPayResult entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['failReason'] = entity.failReason;
  data['finishTime'] = entity.finishTime;
  data['orderFinanceId'] = entity.orderFinanceId;
  data['orderId'] = entity.orderId;
  data['payCode'] = entity.payCode;
  data['payMethod'] = entity.payMethod;
  data['payMsg'] = entity.payMsg;
  data['payStatus'] = entity.payStatus;
  data['payTime'] = entity.payTime;
  data['payType'] = entity.payType;
  data['prePayTn'] = entity.prePayTn;
  data['success'] = entity.success;
  return data;
}

extension PayResultPayResultExtension on PayResultPayResult {
  PayResultPayResult copyWith({
    String? failReason,
    String? finishTime,
    String? orderFinanceId,
    String? orderId,
    String? payCode,
    String? payMethod,
    String? payMsg,
    int? payStatus,
    String? payTime,
    String? payType,
    String? prePayTn,
    bool? success,
  }) {
    return PayResultPayResult()
      ..failReason = failReason ?? this.failReason
      ..finishTime = finishTime ?? this.finishTime
      ..orderFinanceId = orderFinanceId ?? this.orderFinanceId
      ..orderId = orderId ?? this.orderId
      ..payCode = payCode ?? this.payCode
      ..payMethod = payMethod ?? this.payMethod
      ..payMsg = payMsg ?? this.payMsg
      ..payStatus = payStatus ?? this.payStatus
      ..payTime = payTime ?? this.payTime
      ..payType = payType ?? this.payType
      ..prePayTn = prePayTn ?? this.prePayTn
      ..success = success ?? this.success;
  }
}